{% extends 'base.html' %}
{% load static %}
{% block mycss %}
    <link rel="stylesheet" type="text/css" href="{% static 'js/plugins/queryCity/css/cityLayout.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/lq.datetimepick.css' %}"/>
    {% block mycss1 %}{% endblock %}
{% endblock %}

{% block middle %}
    <div class="middle">
        <div class="wp">
            <a href="/"><img class="fl" src="{% static 'images/logo.png' %}"/></a>
            <h1>我的在线教育网</h1>
        </div>
    </div>
{% endblock %}

{% block content %}
        <section>
        <div class="wp">
            <ul  class="crumbs">
                <li><a href="/">首页</a>></li>
                <li><a href="{% url 'users:user_info' %}">个人中心</a>></li>
                <li>{% block breach %}个人信息{% endblock %}</li>
            </ul>
        </div>
    </section>

    <section>
	    <div class="wp list personal_list">
	        <div class="left">
                <ul>
                    <li {% if request.path == '/users/user_info/' %}class="active2"{% endif %}><a href="{% url 'users:user_info' %}">个人资料</a></li>
                    <li {% if request.path == '/users/user_info/course' %}class="active2"{% endif %}><a href="{% url 'users:user_info_course' %}">我的课程</a></li>
                    <li {% if request.path|slice:'20' == '/users/user_info/fav' %}class="active2"{% endif %}><a href="{% url 'users:user_info_fav_org' %}">我的收藏</a></li>
                    <li {% if request.path == '/users/user_info/message' %}class="active2"{% endif %}><a href="{% url 'users:user_info_message' %}">我的消息</a></li>
                </ul>
	        </div>
            {% block right %}
            {% endblock %}
	    </div>
    </section>
    {% block dialog %}
    <div class="dialog" id="jsDialog">
        <div class="resetpwdbox dialogbox" id="jsResetDialog">
        <h1>修改密码</h1>
        <div class="close jsCloseDialog"><img src="{% static 'images/dig_close.png' %}"/></div>
        <div class="cont">
            <form id="jsResetPwdForm" method="post" action="{% url 'users:user_reset' %}" autocomplete="off">
                {% csrf_token %}
                <div class="box">
                    <span class="word2" >新&nbsp;&nbsp;密&nbsp;&nbsp;码</span>
                    <input type="password" id="pwd" name="password1" placeholder="6-20位非中文字符"/>
                </div>
                <div class="box">
                    <span class="word2" >确定密码</span>
                    <input type="password" id="repwd" name="password2" placeholder="6-20位非中文字符"/>
                </div>
                <div class="error btns" id="jsResetPwdTips"></div>
                <div class="button">
                    <input id="jsResetPwdBtn" type="button" value="提交" />
                </div>
            </form>
        </div>
    </div>
        <div class="dialogbox changeemai1 changephone" id="jsChangeEmailDialog">
        <h1>修改邮箱</h1>
        <div class="close jsCloseDialog"><img src="{% static 'images/dig_close.png' %}"/></div>
        <p>请输入新的邮箱地址</p>
        <form id="jsChangeEmailForm" autocomplete="off">
            <div class="box">
                <input class="fl change_email" name="email" id="jsChangeEmail" type="text" placeholder="输入重新绑定的邮箱地址">
            </div>
            <div class="box">
                <input class="fl email_code" type="text" id="jsChangeEmailCode" name="code" placeholder="输入邮箱验证码">
                <input class="getcode getting" type="button" id="jsChangeEmailCodeBtn" value="获取验证码">
            </div>
            <div class="error btns change_email_tips" id="jsChangeEmailTips" >请输入...</div>
            <div class="button">
                <input class="changeemai_btn" id="jsChangeEmailBtn" type="button" value="完成"/>
            </div>
            <input type='hidden' name='csrfmiddlewaretoken' value='DaP7IUKm9FA9nELA9YUlYYWpyIDdCiIP' />
        <input type='hidden' name='csrfmiddlewaretoken' value='799Y6iPeEDNSGvrTu3noBrO4MBLv6enY' />
        </form>
    </div>
    </div>
    <div class="bg" id="dialogBg"></div>
    {% endblock %}
{% endblock %}

{% block footer %}

{% endblock %}

{% block myjs %}
    <script src='{% static 'js/plugins/jquery.upload.js' %}' type='text/javascript'></script>
    <script src="{% static 'js/validate.js' %}" type="text/javascript"></script>

    <script>
        $(function () {
            $('#jsChangeEmailCodeBtn').click(function () {
                var email = $('#jsChangeEmail').val();
                $.ajax({
                    url: '{% url 'users:update_email' %}',
                    type: 'POST',
                    data: {
                        "email": email,
                        "csrfmiddlewaretoken": '{{ csrf_token }}'
                    },
                    success: function (callback) {
                        if (callback.status == 'ok') {
                            alert(callback.msg)
                        } else {
                            alert(callback.msg)
                        }
                    }
                })
            })
            $('#jsChangeEmailBtn').click(function () {
                var email = $('#jsChangeEmail').val();
                var code = $('#jsChangeEmailCode').val()
                $.ajax({
                    url: '{% url 'users:reset_email' %}',
                    type: 'POST',
                    data: {
                        "email": email,
                        "code": code,
                        "csrfmiddlewaretoken": '{{ csrf_token }}',
                    },
                    success: function (callback) {
                        if (callback.status == 'ok'){
                            alert(callback.msg)
                            window.location.href = '{% url 'users:user_login' %}'
                        } else {
                            alert(callback.msg)
                        }
                    }
                })
            })
        })
    </script>
    {% block myjs1 %} {% endblock %}
{% endblock %}
